package com.jbm.jbmsupplier.presenters;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.jbm.jbmsupplier.modes.TerMinorModes;
import com.jbm.jbmsupplier.net.NetIntent;
import com.jbm.jbmsupplier.views.TerMinorViews;
import com.jbm.onehome.iface.IJOrder;
/**
 * Created by 家帮忙 on 2017/7/7.
 */

public class TerMinorActivitys implements TerMinorModes{
    private Context context;
  private TerMinorViews terMinorViews;
    private final int ZZDD=0001;

    public TerMinorActivitys(Context context, TerMinorViews terMinorViews) {
        this.context = context;
        this.terMinorViews = terMinorViews;
    }
public void getTerData(int orid, String ms){
    setTerDate(orid,ms);
}
    @Override
    public void setTerDate(int orid, String ms) {//提交数据
        NetIntent netIntent=new NetIntent(handler);
        netIntent.setTerminOr(orid,ms,ZZDD);
    }
    Handler handler=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case ZZDD:
                    IJOrder zzor=(IJOrder)msg.obj;
                    if (zzor.m_code==200){
//                   startActivity(new Intent(TerMinorActivity.this,MainActivity.class));
                        terMinorViews.setSucced();
                    }else if (zzor.equals("网络超时")){
                        terMinorViews.setError(zzor.m_info);
                    }else if (zzor.m_code==500){
                        terMinorViews.setError(zzor.m_info);
                    }else{
                        terMinorViews.setError(zzor.m_info);
                    }
                    break;
            }
        }
    };

}
